
package com.insigma.business.qrcode.pay.dto;

import com.insigma.business.qrcode.common.converter.AbstractConverter;
import com.insigma.business.qrcode.pay.dto.request.MerchantOrderInsertRequest;
import com.insigma.business.qrcode.pay.dto.request.MerchantOrderSearchRequest;
import com.insigma.business.qrcode.pay.dto.request.MerchantOrderUpdateRequest;
import com.insigma.business.qrcode.pay.entity.MerchantOrder;
import org.springframework.beans.BeanUtils;

import java.util.List;


public class MerchantOrderProviderConverter extends AbstractConverter<MerchantOrderDTO, MerchantOrder> {

    private final static MerchantOrderProviderConverter MerchantOrderConverter = new MerchantOrderProviderConverter();

    private MerchantOrderProviderConverter(){}

    
    public static MerchantOrderBSearcher convertRequestSO2Searcher(final MerchantOrderSearchRequest request){
        final MerchantOrderBSearcher MerchantOrderBSearcher = new MerchantOrderBSearcher(request.getPageNo(),
        request.getPageSize(),request.getSortKeyValueJoint());
        BeanUtils.copyProperties(request,MerchantOrderBSearcher);
        return MerchantOrderBSearcher;
    }

    
    public static MerchantOrder convertRequestUO2DO(final MerchantOrderUpdateRequest MerchantOrderUpdateRequest) {
        final MerchantOrder MerchantOrder = new MerchantOrder();
        BeanUtils.copyProperties(MerchantOrderUpdateRequest,MerchantOrder);
        
        return MerchantOrder;
    }

    
    public static MerchantOrder convertRequestIO2DO(final MerchantOrderInsertRequest MerchantOrderInsertRequest) {
        final MerchantOrder MerchantOrder = new MerchantOrder();
        BeanUtils.copyProperties(MerchantOrderInsertRequest,MerchantOrder);
        return MerchantOrder;
    }

    
    public static List<MerchantOrderDTO> convertResponseDOList2DTOList(final List<MerchantOrder> MerchantOrderList){
        return MerchantOrderConverter.convertGenericResponseDOList2DTOList(MerchantOrderList);
    }

    
    public static MerchantOrderDTO convertResponseDO2DTO(final MerchantOrder MerchantOrder){
        return MerchantOrderConverter.convertGenericResponseDO2DTO(MerchantOrder);
    }

    
    @Override
    protected MerchantOrderDTO doConvertResponseDO2DTO(MerchantOrder MerchantOrder) {
        final MerchantOrderDTO MerchantOrderDTO = new MerchantOrderDTO();
        try {
            BeanUtils.copyProperties(MerchantOrder, MerchantOrderDTO);
        }catch(RuntimeException be){
            
            return null;
        }
        return MerchantOrderDTO;
    }

}
